#!/usr/bin/python3
fname = '/etc/onboard/onboard-defaults.conf'

try:
    with open(fname, 'r') as inp:
        lines = inp.readlines()

    with open(fname, 'w') as out:
        for line in lines:
            if line.strip().startswith('in-use'):
                print('in-use=False', file=out)
            elif line.strip().startswith('docking-enable'):
                print('docking-enabled=False', file=out)
            else:
                print(line.strip(), file=out)

except FileNotFoundError:
    print(f'No file {fname}')

fname = '/usr/share/onboard/layouts/key_defs.xml'

try:
    with open(fname, 'r') as inp:
        lines = inp.readlines()

    with open(fname, 'w') as out:
        for line in lines:
            if "<key_template id='RALT'" in line:
                print("    <key_template id='RALT' keycode='108' label='Язык'   modifier='mod5'    action='single-stroke'/>", file=out)
            else:
                print(line.rstrip(), file=out)

except FileNotFoundError:
    print(f'No file {fname}')
